package com.genghis.rapidcrm.kernel;

import com.genghis.rapidcrm.kernel.module.RapidModuleModel;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * @author xulixin
 */
@Component
public class RapidListViewModelProvider {

    private final ApplicationContext applicationContext;

    public RapidListViewModelProvider(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    public RapidListViewModel getInstance(String module) {
        return getInstance(module, "0");
    }

    public RapidListViewModel getInstance(String module, String viewId) {
        RapidListViewModel listViewModel = RapidModelBeanHelper.getListViewModelBean(module, applicationContext);
        RapidModuleModel moduleModel = RapidModelBeanHelper.getModuleModelBean(module, applicationContext);
        listViewModel.setModule(moduleModel);
        return listViewModel;
    }
}
